
#include "TaylorGreenVortexIC.h"
#include "CFDProblem.h"
#include "Eigen/Geometry"
using namespace Eigen;

template<>
InputParameters validParams<TaylorGreenVortexIC>()
{
  InputParameters params = validParams<CFDInitialCondition>();
  return params;
}

TaylorGreenVortexIC::TaylorGreenVortexIC(const InputParameters & parameters) :
	CFDInitialCondition(parameters),
	_gamma(_cfd_problem._gamma),
	_mach(_cfd_problem._mach)
{}


Real TaylorGreenVortexIC::value(const Point & p)
{
	Real x = p(0);
	Real y = p(1);
	Real z = p(2);

	Real density = 1;
	Vector3d vel(sin(x)*cos(y)*cos(z), -cos(x)*sin(y)*cos(z), 0);
	Vector3d mom(density*vel);
	Real pre = 1/_gamma/_mach/_mach + (cos(2*x)+cos(2*y))*(cos(2*z)+2)/16.;
	Real rhoe = pre/(_gamma-1) + 0.5*density*(vel.squaredNorm());

	_cfd_data.uh[0] = density;
	_cfd_data.uh[1] = mom(0);
	_cfd_data.uh[2] = mom(1);
	_cfd_data.uh[3] = mom(2);
	_cfd_data.uh[4] = rhoe;

	return _cfd_data.uh[_component];
}
